import { mapGetters, createNamespacedHelpers } from 'vuex'
import { useStateMapper } from './useMapper'
import { checkType } from '@/utils'

export default function useGetters(moduleName, mapper) {
  let mapperFn = mapGetters

  if (checkType(moduleName) === 'String' && moduleName.length > 0) {
    mapperFn = createNamespacedHelpers(moduleName)
  }

  return useStateMapper(mapper, mapperFn)
}
